home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / picture / anring.c < prev    next >
Text File  |  1993-09-23  |  1KB  |  56 lines

  1. //    Copyright 1993 Ralph Gonzalez
  2.  
  3. /*
  4. *    FILE:        anring.c
  5. *    AUTHOR:        R. Gonzalez
  6. *    CREATED:    November 8, 1990
  7. *
  8. *    defines methods for ring animated segment
  9. */
  10.  
  11. # include    "anring.h"
  12. # include    "trans.h"
  13. # include    "atring.h"
  14. # include    "cube.h"
  15.  
  16. # define    NUM_SATELLITES        2
  17. # define    RADIUS                3.
  18. # define    SATELLITE_TYPE        Atomic_Ring
  19. # define    ANIMATED_SATELLITES    TRUE
  20. # define    ANGULAR_VELOCITY    PI/20.
  21.  
  22. /******************************************************************
  23. *    initialize
  24. ******************************************************************/
  25. Animated_Ring::Animated_Ring(void)
  26. {
  27.     int                i;
  28.     Translation        *transl;
  29.     Rotation_Y        *roty;
  30.     Transformation    *combination;
  31.     
  32.     transl = new Translation;
  33.     transl->set(0.,0.,RADIUS);
  34.     roty = new Rotation_Y;
  35.     combination = new Transformation;
  36.     
  37.     num_segments = NUM_SATELLITES;
  38.     
  39.     for (i=0 ; i<NUM_SATELLITES ; i++)
  40.     {
  41.         segment[i] = new SATELLITE_TYPE;
  42.         roty->set(i*2.*PI/NUM_SATELLITES);
  43.         combination->combine(transl,roty);
  44.         segment[i]->move(combination);
  45.         animation[i] = new Rotation_Y;
  46.         ((Rotation_Y*) animation[i])->set(ANGULAR_VELOCITY);
  47.         if (ANIMATED_SATELLITES)
  48.             log_animated_segment(segment[i]);
  49.     }
  50.     
  51.     delete transl;
  52.     delete roty;
  53.     delete combination;
  54. }
  55.  
  56.